<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>客服 </title>
		<link rel="stylesheet" type="text/css" href="__INDEX__font_Icon/iconfont.css">
		<link rel="stylesheet" type="text/css" href="__INDEX__css/chat.css">
	</head>
	<body>
		<div onclick="wo()">点击</div>
		<script type="text/javascript">
			//这个是聊天系统的核心文件
				if ("WebSocket" in window) {
					
					//打开一个 web socket
					var ws = new WebSocket("ws://127.0.0.1:8282");
					ws.onopen = function() {
						let data={ //初始化操作
							type:'init',
							formid:"main"   //这里默认客服编号为1
						};
						ws.send(JSON.stringify(data));
					};
					ws.onmessage = function(evt) {
						var msg = JSON.parse(evt.data);
						
							
						console.log(msg)
					};
					ws.onclose = function() {
						// 关闭 websocket
						alert("连接已关闭...");
					};
				} else {
					// 浏览器不支持 WebSocket
					alert("您的浏览器不支持 WebSocket!");
				}
			function wo(){
				let data={ //初始化操作
							type:'init111111111111',
							formid:"main11111111111111"   //这里默认客服编号为1
						};
						ws.send(JSON.stringify(data));
			}
		</script>
		<div style="text-align:center;margin:50px 0; font:normal 14px/24px 'MicroSoft YaHei';">
		</div>
	</body>
</html>
